import axios from '@/http/axios'
export default{
    namespaced:true,
    state:{
        productData:[],
        allProducts:[]
    },
    getters:{},
    mutations:{
        setProductData(state,data){
            state.productData=data
        },
        setAllProducts(state,data){
            state.allProducts=data
        }
    },
    actions:{
        async toLoadAllProducts(context,params){
            let res = await axios.get('/product/findAll')
            context.commit('setAllProducts',res.data.data)
        },
        async toDeleteProducts(context,params){
            let res = await axios.get('/product/deleteById?id='+params)
        },
        async toSaveProducts(context,params){
            return await axios.post('/product/saveOrUpdate',params)
        },
        async toLoadProducts(context,params){
            let res = await axios.post('/product/query',params)
            context.commit('setProductData',res.data.data)
        }
    }
}